package cn.xiaye.blog.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.xiaye.blog.bean.Context;

public abstract class FatherServlet extends HttpServlet {
	/**
	 * 
	 */
	private static final long serialVersionUID = -5390011856761213563L;

	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		this.doPost(req, resp);
	}

	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		req.setCharacterEncoding("GBK");
		Context context = new Context(req, resp);
		String disp = this.excute(context);
		if (disp != null) {
			req.getRequestDispatcher(disp).forward(req, resp);
		}
	}

	public abstract String excute(Context context);
}
